//
//  GoodListTableViewCell.m
//  SafeFoodManagerDemo
//
//  Created by bob on 2017/10/26.
//  Copyright © 2017年 bob. All rights reserved.
//

#import "GoodListTableViewCell.h"

@implementation GoodListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)setIsClick:(BOOL)isClick
{
    _isClick=isClick;
    
    if (self.isClick) {
        self.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    }else{
        self.accessoryType=UITableViewCellAccessoryNone;
    }
    
}

-(void)setDeleStatue:(BOOL)deleStatue
{
    _deleStatue=deleStatue;
    
    if (deleStatue) {
        
        self.editImageView.hidden=NO;
     
        self.accessoryType=UITableViewCellAccessoryNone;
        
    }else{
        
        self.editImageView.hidden=YES;
   
        if (self.isClick) {
            self.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        }else{
            self.accessoryType=UITableViewCellAccessoryNone;
        }
        
        
    }
    
}

-(void)setListModel:(GoodListData *)listModel
{
    _listModel=listModel;
    
    if (listModel.unit==nil) {
        
        listModel.unit=@"";
    }
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@(%@)",listModel.goodsName,listModel.unit]];
    
    [AttributedStr addAttribute:NSForegroundColorAttributeName value:TBColorSubTitle range:NSMakeRange(listModel.goodsName.length, listModel.unit.length+2)];
    
    self.GCNameLabel.attributedText=AttributedStr;
    
    if (self.isClick) {
        
        self.ShopNameLabel.text=@"";

        if (listModel.Seleclt) {
            
            self.editImageView.image=[UIImage imageNamed:@"Select"];
            
        }else{
            
            self.editImageView.image=[UIImage imageNamed:@"UnSelect"];
        }
        
    }else{
        self.ShopNameLabel.text=listModel.shopName;
        
    }
}


-(void)setCataModel:(GoodCataData *)CataModel
{
    _CataModel=CataModel;
    
    self.GCNameLabel.text=CataModel.catName;
    
    if (self.isClick) {
        
        self.ShopNameLabel.text=@"";
        
        if (CataModel.Seleclt) {
            
            self.editImageView.image=[UIImage imageNamed:@"Select"];
            
        }else{
            
            self.editImageView.image=[UIImage imageNamed:@"UnSelect"];
        }
        
    }else{
        self.ShopNameLabel.text=CataModel.shopName;
        
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
